package com.ai.tikai.service.impl;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MessageProducer {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void sendMessage(String message) {
        // 参数说明:
        // 1. exchange: 交换机名称
        // 2. routingKey: 路由键
        // 3. object: 发送的消息体
        rabbitTemplate.convertAndSend("my-direct-exchange", "my-routing-key", message);
        System.out.println("消息已发送: " + message);
    }
}
